package com.example.travel.config;

import com.example.travel.entity.TravelPackage;
import com.example.travel.repository.TravelPackageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.LocalDate;

@Component
public class DataInitializer implements CommandLineRunner {

    @Autowired
    private TravelPackageRepository travelPackageRepository;

    @Override
    public void run(String... args) {
        // 检查是否已有数据
        if (travelPackageRepository.count() == 0) {
            // 昆明七日游
            TravelPackage package1 = new TravelPackage();
            package1.setTitle("昆明七日游");
            package1.setDescription("畅游春城，领略高原明珠的自然与人文之美。");
            package1.setPrice(new BigDecimal("8999"));
            package1.setImage("https://images-1333018258.cos.ap-chengdu.myqcloud.com/travel%2Fsili.png");
            package1.setItinerary("石林探奇、滇池观鸟、西山龙门、云南民族村。");
            package1.setDepartureDate(LocalDate.parse("2024-02-15"));
            package1.setServices("包含往返机票、四星级酒店、每日三餐、中文导游、景点门票与全程交通。");
            package1.setHighlights("走进世界自然遗产石林，体验喀斯特地貌的神奇魅力。乘船游览滇池，观赏红嘴鸥冬季盛景。登临西山龙门俯瞰昆明全景，感受高原湖城之美。");
            package1.setDirection("昆明");
            travelPackageRepository.save(package1);

            // 昆明十日深度游
            TravelPackage package2 = new TravelPackage();
            package2.setTitle("昆明十日深度游");
            package2.setDescription("深入探索春城自然风光与多彩民族文化。");
            package2.setPrice(new BigDecimal("4999"));
            package2.setImage("https://images-1333018258.cos.ap-chengdu.myqcloud.com/travel%2Fhainan.png");
            package2.setItinerary("游览大观楼、翠湖、官渡古镇、九乡溶洞。");
            package2.setDepartureDate(LocalDate.parse("2024-03-01"));
            package2.setServices("包含机票、精品酒店、全程接送、中文导游和门票。");
            package2.setHighlights("漫步翠湖公园，看春日海鸥翻飞。穿越九乡溶洞，体验地下溶洞奇观。在官渡古镇品味昆明老街文化与地道小吃。");
            package2.setDirection("昆明");
            travelPackageRepository.save(package2);

            // 昆明春季五日赏花游
            TravelPackage package3 = new TravelPackage();
            package3.setTitle("昆明春季五日赏花游");
            package3.setDescription("邂逅昆明春天的花海与温润气候，开启赏花之旅。");
            package3.setPrice(new BigDecimal("6999"));
            package3.setImage("https://images-1333018258.cos.ap-chengdu.myqcloud.com/travel%2Fjapan.png");
            package3.setItinerary("探访圆通山、斗南花市、呈贡樱花大道。");
            package3.setDepartureDate(LocalDate.parse("2024-04-05"));
            package3.setServices("包含机票、精品民宿、接送服务、本地导游和特色美食。");
            package3.setHighlights("在圆通山公园欣赏盛开的樱花与杜鹃。感受亚洲最大鲜切花市场——斗南花市的繁花世界。漫步呈贡春季花海大道，体验\"花都\"的浪漫。");
            package3.setDirection("昆明");
            travelPackageRepository.save(package3);

            // 滇中风情五日游
            TravelPackage package4 = new TravelPackage();
            package4.setTitle("滇中风情五日游");
            package4.setDescription("感受滇中文化与自然风光的完美融合。");
            package4.setPrice(new BigDecimal("9999"));
            package4.setImage("https://images-1333018258.cos.ap-chengdu.myqcloud.com/travel%2Feu.png");
            package4.setItinerary("行摄东川红土地、普达措森林公园、黑龙潭公园。");
            package4.setDepartureDate(LocalDate.parse("2024-06-10"));
            package4.setServices("包含机票、特色客栈、云南风味餐、导游讲解及门票。");
            package4.setHighlights("置身东川红土地，如同走进彩色油画世界。游走于普达措国家公园，体验高原森林的静谧之美。探访黑龙潭，领略滇池源头的灵动风景。");
            package4.setDirection("昆明");
            travelPackageRepository.save(package4);
        }
    }
} 